<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>
       <ui:composition template="./../../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <h:form id="form4" prependId="false">
                    <p:panel id="rawMaterial" header="View Raw Material Inventory" style="height:495px;">
                        <div style="margin-left:50px;margin-right:50px;">


                            <p:dataTable id="RMinventory" value="#{viewRawMaterialInventoryManagedBean.getRMInventories()}" var="RMinventoryList">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Raw Material" />
                                    </f:facet>
                                    <h:outputText value="#{RMinventoryList.rawMaterial.rawMaterialName}" />
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Incoming quantity" />
                                    </f:facet>
                                    <h:outputText value="#{RMinventoryList.incomingQty}" />
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Current Inventory Level" />
                                    </f:facet>
                                    <h:outputText value="#{RMinventoryList.currentLevel}" />
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Safety Stock"/>
                                    </f:facet>
                                    <h:outputText value="#{RMinventoryList.safetyStock}" />
                                </p:column>
                               
                                <p:column style="width:65px;">
                                    <f:facet name="header">View Records</f:facet>

                                    <p:commandButton update=":form4:display" oncomplete="viewDetailsDialog.show()" image="ui-icon ui-icon-search" title="View"  >
                                         <f:setPropertyActionListener value="#{RMinventoryList}" target="#{viewRawMaterialInventoryManagedBean.selectedInventory}" />  
                                                  
                                    </p:commandButton>
                                </p:column>  

                                
                          
                            </p:dataTable>
                            <br />
                            
                              <p:dialog header="Inventory Detail" widgetVar="viewDetailsDialog" resizable="false" id="viewDetails" showEffect="fade" hideEffect="explode" modal="true" width="700">  
                       
                            <h:panelGrid id="display" cellpadding="0" style="margin:0 auto;"> 
                                
                                <p:dataTable id="recordDetail" dynamic="true"   value="#{viewRawMaterialInventoryManagedBean.selectedInventory.rawMaterialBatchRecord}" var ="recordList" >

                                    <p:column>
                                        <f:facet name="header">Batch Record Id</f:facet>
                                        #{recordList.id}
                                    </p:column>

                                    <p:column>
                                        <f:facet name="header">Arrival Date</f:facet>
                                        <h:outputText value="#{recordList.arrivalDate}" >
                                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                                        </h:outputText>
                                        
                                    </p:column> 

                                    <p:column>
                                        <f:facet name="header"> Quantity</f:facet>
                                        #{recordList.quantity}
                                    </p:column> 
                                    <p:column>
                                        <f:facet name="header">Warehouse Location</f:facet>
                                        #{recordList.warehouseLocation}
                                    </p:column> 
                                 
                                </p:dataTable>




                            </h:panelGrid>
                        </p:dialog>
                             </div>
                    </p:panel>

                </h:form>

            </ui:define>

        </ui:composition>



    </body>
</html>
